package com.wuxianedu.wechat.ui.adapter;

import java.util.List;

import com.wuxianedu.wechat.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class ExpressionsAdapter extends BaseAdapter{
	
	private Context context;
	private List<Integer> list;
	
	public ExpressionsAdapter(Context context,List<Integer> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView == null){
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.fragment_expression_item, null);
			holder.iv_expressions_item = (ImageView) convertView.findViewById(R.id.iv_expressions_item);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		
		int image = list.get(position);
		
		holder.iv_expressions_item.setImageResource(image);
		
		return convertView;
	}
	
	class ViewHolder{
		ImageView iv_expressions_item;
	}

}
